// 蜂窝蜜造平台生成代码，此文件只生成一次，不需要添加到 .beeignore

package com.fowo.api.service.impl;

import com.fowo.api.model.stock.in.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 成品入库单 服务实现类
 */
@Service
public class StockInFinishedProductServiceImpl
  extends StockInFinishedProductBaseServiceImpl {
    @Autowired(required = false)
    protected StockInPushPayableAction stockInPushPayableAction;
    @Autowired(required = false)
    protected StockInPushStockOtherAction stockInPushStockOtherAction;
    @Autowired(required = false)
    protected StockInPushSellOrderAction stockInPushSellOrderAction;
    @Autowired(required = false)
    protected StockInPushLingXingAction stockInPushLingXingAction;
    @Autowired(required = false)
    protected StockInSyncWarehousingOrderAction stockInSyncWarehousingOrderAction;

    /**
     * 批量下推应付单
     */
//    @Override
//    public void batchPushPy(List<Long> ids) throws Exception {
//        if (stockInPushPayableAction == null) {
//            throw new Exception("此操作当前不可用");
//        }
//        for(int i=0;i<ids.size();i++){
//            Long aLong = ids.get(i);
//            stockInPushPayableAction.run(aLong);
//        }
//    }

    /**
     * 下推其他出库单
     */
    @Override
    public void pushStockOther(Long id) throws Exception {
        if (stockInPushStockOtherAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockInPushStockOtherAction.run(id);
    }

    /**
     * 下推销售出库单
     */
    @Override
    public void pushSellOrder(Long id) throws Exception {
        if (stockInPushSellOrderAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockInPushSellOrderAction.run(id);
    }

    /**
     * 下推应付单
     */
    @Override
    public void pushPayable(Long id) throws Exception {
        if (stockInPushPayableAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockInPushPayableAction.run(id);
    }

    /**
     * 推送领星
     */
    @Override
    public void pushLingXing(Long id) throws Exception {
        if (stockInPushLingXingAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockInPushLingXingAction.run(id);
    }

    /**
     * 同步领星入库单
     */
    @Override
    public void syncWarehousingOrder() throws Exception {
        if (stockInSyncWarehousingOrderAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockInSyncWarehousingOrderAction.run();
    }

    /**
     * 批量下推应付单
     */
    @Override
    public void batchPushPy(List<Long> ids) throws Exception {
        if (stockInPushPayableAction == null) {
            throw new Exception("此操作当前不可用");
        }
        for(Long id : ids){
            stockInPushPayableAction.run(id);
        }
    }
}
